<%@ page contentType="text/html;charset=UTF-8" language="java" %>
    <%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
        <%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions" %>

            <html lang="zh">

            <head>
                <meta charset="UTF-8">
                <meta name="viewport" content="width=device-width, initial-scale=1.0">
                <title>全部图书信息</title>
                <link rel="shortcut icon" href="img/library.ico" />
                <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/css/bootstrap.min.css">
                <script src="https://cdn.jsdelivr.net/npm/jquery@3.6.0/dist/jquery.min.js"></script>
                <script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/js/bootstrap.bundle.min.js"></script>

                <style>
                    body {
                        font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
                        background-image: url('img/华师2.jpg.v');
                        /* 更改为你想使用的图片路径 */
                        background-size: cover;
                        /* 保证图片覆盖整个背景 */
                        background-position: center center;
                        /* 确保图片居中显示 */
                        color: var(--dark-text);
                        min-height: 100vh;
                        padding-top: 60px;
                    }

                    .navbar {
                        background-color: #fff !important;
                        box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
                        padding: 10px 0;
                        position: fixed;
                        top: 0;
                        width: 100%;
                        z-index: 1000;
                    }

                    .navbar-brand p {
                        font-family: "华文行楷", "楷体", cursive;
                        font-size: 28px;
                        font-weight: bold;
                        color: #337ab7 !important;
                        margin: 0;
                    }

                    .navbar-nav .nav-link {
                        color: #333 !important;
                        font-weight: 500;
                        padding: 10px 15px;
                        transition: all 0.3s ease;
                    }

                    .navbar-nav .nav-link:hover {
                        color: #fff !important;
                        background-color: #337ab7 !important;
                    }

                    .main-container {
                        max-width: 1200px;
                        margin: 60px auto;
                        padding: 20px;
                    }

                    .page-title {
                        text-align: center;
                        margin-bottom: 40px;
                        color: #333;
                    }

                    .page-title h1 {
                        font-size: 2.8rem;
                        margin-bottom: 10px;
                        position: relative;
                        display: inline-block;
                    }

                    .page-title h1::after {
                        content: '';
                        position: absolute;
                        bottom: -10px;
                        left: 50%;
                        transform: translateX(-50%);
                        width: 100px;
                        height: 4px;
                        background: #3498db;
                        border-radius: 2px;
                    }

                    .page-title p {
                        font-size: 1.2rem;
                        max-width: 600px;
                        margin: 20px auto 0;
                        color: rgba(0, 0, 0, 0.7);
                        line-height: 1.6;
                    }

                    .panel {
                        background: #fff;
                        box-shadow: 0 0 20px rgba(0, 0, 0, 0.1);
                        margin-top: 20px;
                        border-radius: 10px;
                    }

                    .panel-heading {
                        background-color: #f8f9fa;
                        padding: 15px;
                        border-radius: 10px 10px 0 0;
                    }

                    .panel-body {
                        padding: 20px;
                    }

                    table {
                        width: 100%;
                        margin-bottom: 20px;
                        border-collapse: collapse;
                    }

                    th,
                    td {
                        padding: 10px;
                        text-align: left;
                        border: 1px solid #ddd;
                    }

                    th {
                        background-color: #f8f9fa;
                    }

                    tr:hover {
                        background-color: #f1f1f1;
                    }

                    .btn {
                        border-radius: 5px;
                        font-weight: bold;
                    }

                    .btn-primary {
                        background-color: #3498db;
                        border-color: #3498db;
                    }

                    .btn-primary:hover {
                        background-color: #2980b9;
                        border-color: #2980b9;
                    }

                    .btn-danger {
                        background-color: #e74c3c;
                        border-color: #e74c3c;
                    }

                    .btn-danger:hover {
                        background-color: #c0392b;
                        border-color: #c0392b;
                    }

                    .btn-success {
                        background-color: #2ecc71;
                        border-color: #2ecc71;
                    }

                    .btn-success:hover {
                        background-color: #27ae60;
                        border-color: #27ae60;
                    }

                    .alert {
                        border-radius: 5px;
                    }
                </style>
            </head>

            <body>

                <!-- 自定义导航栏 -->
                <nav class="navbar navbar-expand-lg navbar-light" style="background-color:#fff">
                    <div class="container-fluid">
                        <a class="navbar-brand" href="reader_main.html">
                            <p class="text-primary" style="font-family: 华文行楷; font-size: 28px;">智慧图书馆</p>
                        </a>
                        <button class="navbar-toggler" type="button" data-bs-toggle="collapse"
                            data-bs-target="#navbarNav">
                            <span class="navbar-toggler-icon"></span>
                        </button>
                        <div class="collapse navbar-collapse" id="navbarNav">
                            <ul class="navbar-nav me-auto">
                                <li class="nav-item">
                                    <a class="nav-link" href="reader_books.html">图书查询</a>
                                </li>
                                <li class="nav-item">
                                    <a class="nav-link" href="reader_info.html">个人信息</a>
                                </li>
                                <li class="nav-item">
                                    <a class="nav-link" href="mylend.html">我的借还</a>
                                </li>
                                <li class="nav-item">
                                    <a class="nav-link" href="reader_repasswd.html">密码修改</a>
                                </li>
                            </ul>
                            <ul class="navbar-nav">
                                <li class="nav-item">
                                    <a class="nav-link" href="reader_info.html">${readercard.name}, 已登录</a>
                                </li>
                                <li class="nav-item">
                                    <a class="nav-link" href="login.html">退出</a>
                                </li>
                            </ul>
                        </div>
                    </div>
                </nav>

                <!-- 头部内容 -->
                <div id="header"></div>

                <!-- 搜索表单 -->
                <div style="padding: 20px 550px 10px">
                    <form method="post" action="reader_querybook_do.html" class="form-inline" id="searchform">
                        <div class="input-group">
                            <input type="text" placeholder="输入图书名" class="form-control" id="search" name="searchWord">
                            <span class="input-group-btn">
                                <input type="submit" value="搜索" class="btn btn-primary">
                            </span>
                        </div>
                    </form>
                    <script>
                        $("#searchform").submit(function () {
                            var val = $("#search").val();
                            if (val == '') {
                                alert("请输入关键字");
                                return false;
                            }
                        })
                    </script>
                </div>

                <!-- 显示信息 -->
                <div style="position: relative;top: 10%">
                    <c:if test="${!empty succ}">
                        <div class="alert alert-success alert-dismissible fade show" role="alert">
                            ${succ}
                            <button type="button" class="btn-close" data-bs-dismiss="alert" aria-label="Close"></button>
                        </div>
                    </c:if>
                    <c:if test="${!empty error}">
                        <div class="alert alert-danger alert-dismissible fade show" role="alert">
                            ${error}
                            <button type="button" class="btn-close" data-bs-dismiss="alert" aria-label="Close"></button>
                        </div>
                    </c:if>
                </div>

                <!-- 图书展示 -->
                <div class="panel panel-default" style="width: 90%; margin-left: 5%">
                    <div class="panel-heading" style="background-color: #fff">
                        <h3 class="panel-title">全部图书</h3>
                    </div>
                    <div class="panel-body">
                        <table class="table table-hover">
                            <thead>
                                <tr>
                                    <th>书名</th>
                                    <th>作者</th>
                                    <th>出版社</th>
                                    <th>ISBN</th>
                                    <th>价格</th>
                                    <th>剩余数量</th>
                                    <th>借还</th>
                                    <th>详情</th>
                                </tr>
                            </thead>
                            <tbody>
                                <c:forEach items="${books}" var="book">
                                    <tr>
                                        <td>
                                            <c:out value="${book.name}"></c:out>
                                        </td>
                                        <td>
                                            <c:out value="${book.author}"></c:out>
                                        </td>
                                        <td>
                                            <c:out value="${book.publish}"></c:out>
                                        </td>
                                        <td>
                                            <c:out value="${book.isbn}"></c:out>
                                        </td>
                                        <td>
                                            <c:out value="${book.price}"></c:out>
                                        </td>
                                        <td>
                                            <c:out value="${book.number}"></c:out>
                                        </td>
                                        <c:set var="flag" value="false" />
                                        <c:forEach var="lend" items="${myLendList}">
                                            <c:if test="${lend eq book.bookId}">
                                                <c:set var="flag" value="true" />
                                            </c:if>
                                        </c:forEach>
                                        <c:if test="${flag}">
                                            <td><a href="returnbook.html?bookId=<c:out value=" ${book.bookId}"></c:out>
                                                    ">
                                                    <button type="button" class="btn btn-danger btn-xs">归还</button>
                                                </a></td>
                                        </c:if>
                                        <c:if test="${not flag}">
                                            <c:if test="${book.number > 0}">
                                                <td><a href="lendbook.html?bookId=<c:out value=" ${book.bookId}">
                                                        </c:out>">
                                                        <button type="button" class="btn btn-primary btn-xs">借阅</button>
                                                    </a>
                                                </td>
                                            </c:if>
                                            <c:if test="${book.number == 0}">
                                                <td><button type="button" class="btn btn-default btn-xs"
                                                        disabled="disabled">已空</button></td>
                                            </c:if>
                                        </c:if>
                                        <td><a href="book_detail.html?bookId=${book.bookId}">
                                                <button type="button" class="btn btn-success btn-xs">详情</button>
                                            </a></td>
                                    </tr>
                                </c:forEach>
                            </tbody>
                        </table>
                    </div>
                </div>

            </body>

            </html>